package com.deli.mapper;

import com.deli.entity.TestResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.LinkedHashMap;
import java.util.List;

@Repository(value = "testResultMapper")
public interface TestResultMapper {

    List<TestResult> selectByExample(TestResult testResult);

    Integer updateAnswerByUserNameAndPhoneNum(@Param(value = "userName") String userName,
                                              @Param(value = "phoneNum") String phoneNum,
                                              @Param(value = "answer") String answer,
                                              @Param(value = "breakTime") Long breakTime,
                                              @Param(value = "testType") Integer testType);

    List<LinkedHashMap<String, Object>> getAnswerByUserNameAndPhoneNum(@Param(value = "userName") String userName,
                                                                       @Param(value = "phoneNum") String phoneNum,
                                                                       @Param(value = "testType") int testType);

    List<LinkedHashMap<String,Object>> getResultById(@Param(value = "id") Long id);

    Integer addRecordNoResult(TestResult testResult);

    Integer addRecordWithResult(TestResult testResult);

    Integer updateAnswerAndResultAndBreakTimeByUserNameAndPhoneNum(@Param(value = "userName") String userName,
                                                                   @Param(value = "phoneNum") String phoneNum,
                                                                   @Param(value = "result") String result,
                                                                   @Param(value = "answer") String answer,
                                                                   @Param(value = "breakTime") Long breakTime,
                                                                   @Param(value = "testType") Integer testType);

    List<LinkedHashMap<String, Object>> getExport(@Param(value = "userName") String userName, @Param(value = "departmentname") String departmentname,
                                                  @Param(value = "phoneNum") String mobilePhone, @Param(value = "textfield") String textfield,
                                                  @Param(value = "userPosition") String userPosition, @Param(value = "testType") Integer testType,
                                                  @Param(value = "managername") String managername, @Param(value = "pageNum") int pageNum);

    List<LinkedHashMap<String, Object>> getExportWithStartTime(@Param(value = "userName") String userName, @Param(value = "departmentname") String departmentname,
                                                               @Param(value = "phoneNum") String mobilePhone, @Param(value = "textfield") String textfield,
                                                               @Param(value = "userPosition") String userPosition, @Param(value = "testType") Integer testType,
                                                               @Param(value = "managername") String managername, @Param(value = "startTime") String startTime,
                                                               @Param(value = "pageNum") int pageNum);

    List<LinkedHashMap<String, Object>> getExportWithEndTime(@Param(value = "userName") String userName, @Param(value = "departmentname") String departmentname,
                                                             @Param(value = "phoneNum") String mobilePhone, @Param(value = "textfield") String textfield,
                                                             @Param(value = "userPosition") String userPosition, @Param(value = "testType") Integer testType,
                                                             @Param(value = "managername") String managername, @Param(value = "endTime") String endTime,
                                                             @Param(value = "pageNum") int pageNum);

    List<LinkedHashMap<String, Object>> getExportWithStartTimeAndEndTime(@Param(value = "userName") String userName, @Param(value = "departmentname") String departmentname,
                                                                         @Param(value = "phoneNum") String mobilePhone, @Param(value = "textfield") String textfield,
                                                                         @Param(value = "userPosition") String userPosition, @Param(value = "testType") Integer testType,
                                                                         @Param(value = "managername") String managername, @Param(value = "startTime") String startTime,
                                                                         @Param(value = "endTime") String endTime, @Param(value = "pageNum") int pageNum);

    Integer getExportCount(@Param(value = "userName") String userName, @Param(value = "departmentname") String departmentname,
                           @Param(value = "phoneNum") String mobilePhone, @Param(value = "textfield") String textfield,
                           @Param(value = "userPosition") String userPosition, @Param(value = "testType") Integer testType,
                           @Param(value = "managername") String managername);


    Integer getExportWithEndTimeCount(@Param(value = "userName") String userName, @Param(value = "departmentname") String departmentname,
                                      @Param(value = "phoneNum") String mobilePhone, @Param(value = "textfield") String textfield,
                                      @Param(value = "userPosition") String userPosition, @Param(value = "testType") Integer testType,
                                      @Param(value = "managername") String managername, @Param(value = "endTime") String endTime);

    Integer getExportWithStartTimeCount(@Param(value = "userName") String userName, @Param(value = "departmentname") String departmentname,
                                        @Param(value = "phoneNum") String mobilePhone, @Param(value = "textfield") String textfield,
                                        @Param(value = "userPosition") String userPosition, @Param(value = "testType") Integer testType,
                                        @Param(value = "managername") String managername, @Param(value = "startTime") String startTime);

    Integer getExportWithStartTimeAndEndTimeCount(@Param(value = "userName") String userName, @Param(value = "departmentname") String departmentname,
                                                  @Param(value = "phoneNum") String mobilePhone, @Param(value = "textfield") String textfield,
                                                  @Param(value = "userPosition") String userPosition, @Param(value = "testType") Integer testType,
                                                  @Param(value = "managername") String managername, @Param(value = "startTime") String startTime,
                                                  @Param(value = "endTime") String endTime);
}
